//
//  TravelTipLabel.m
//  ZCProject
//
//  Created by 崔明燃 on 16/11/28.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "TravelTipLabel.h"

@implementation TravelTipLabel

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.titleLabel];
        [self addSubview:self.deleteButton];
        
        [self subViewsLayouWith:@""];
    }
    
    return self;
}

#pragma mark - set model

#pragma mark - layout subViews
- (void)subViewsLayouWith:(NSString *)title {
    NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:20],};
    NSString *str = @"abcdefg你上课可是你的拿到了";
    CGSize textSize = [title boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;;
    [_titleLabel setFrame:CGRectMake(2, 1, textSize.width, textSize.height)];
    
    [_deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-2);
        make.top.equalTo(self.mas_top).offset(2);
        make.width.equalTo(@7);
        make.height.equalTo(@7);
    }];
}

#pragma mark - lazy load
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
    }
    
    return _titleLabel;
}

- (UIButton *)deleteButton {
    if (!_deleteButton) {
        _deleteButton = [[UIButton alloc] init];
        [_deleteButton setBackgroundColor:[UIColor redColor]];
    }
    
    return _deleteButton;
}

@end
